package com.hu.service.impl;

import com.hu.mapper.DeptMapper;
import com.hu.pojo.Dept;
import com.hu.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service

public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;

    //查询操作，调用mapper层
    @Override
    public List<Dept> list(){
        return deptMapper.list();
    }

    @Override
    public void delete(Integer id){
        deptMapper.deteleById(id);
    }

    @Override
    public void add(Dept dept){
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());

        deptMapper.insert(dept);
    }

    @Override
    public Dept getById(Integer id){
        return deptMapper.getByID(id);
    }

    @Override
    public void update(Dept dept) {
        deptMapper.update(dept);
    }
}
